<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>编辑老人健康体检主表</title>
    <#include "/common/resource.ftl">
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
    <style>
        .layui-form select {display:none !important;}
    </style>
    <script>
        $(function () {
            $(".elderHealth-form").unbind().submit(function () {
                var form = $(this);
                if (!form.valid()) {
                    $.message("表单验证不通过，无法提交表单!");
                    return false;
                }
                form.formSubmit({
                    parentClose:false,
                    parentRefresh:false,
                    callBack:function (data) {
                       $(".elderHealth-form").attr("action", '${params.contextPath}/web/elderHealth/<#if (params.id)??>modify<#else>save</#if>.json');
                       var result = data.data;
                       $("input[name='id']").val(result.id || "");
                       $("#elderLifeStyle").attr("src", $.getUrl("${params.contextPath}/view/business/elderLifeStyle/elderLifeStyle_edit.htm", "healthId", result.id));
                       $("#elderOrganFunction").attr("src", $.getUrl("${params.contextPath}/view/business/elderOrganFunction/elderOrganFunction_edit.htm", "healthId", result.id));
                       $("#elderHealthQuestion").attr("src", $.getUrl("${params.contextPath}/view/business/elderHealthQuestion/elderHealthQuestion_edit.htm", "healthId", result.id));
                       $("#elderHospitalization").attr("src", $.getUrl("${params.contextPath}/view/business/elderHospitalization/elderHospitalization_edit.htm", "healthId", result.id));
                       $("#elderPharmacy").attr("src", $.getUrl("${params.contextPath}/view/business/elderPharmacy/elderPharmacy_edit.htm", "healthId", result.id));
                       $("#elderHealthEvaluation").attr("src", $.getUrl("${params.contextPath}/view/business/elderHealthEvaluation/elderHealthEvaluation_edit.htm", "healthId", result.id));
                    }
                });
                return false;
            })
        })
    </script>
</head>
<body>

<div class="layui-tab" lay-filter="test" style="height: 1000px; overflow: hidden;">
    <ul class="layui-tab-title layui-tab-card">
        <li lay-id="22" class="layui-this">老年人健康基本信息</li>
        <li lay-id="33">生活方式</li>
        <li lay-id="44">脏器功能</li>
        <li lay-id="55">现存主要健康问题</li>
        <li lay-id="66">住院治疗情况</li>
        <li lay-id="77">主要用药情况</li>
        <li lay-id="88">健康评价与指导</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <div class="ui-form">
                <form class="layui-form elderHealth-form"
                      action="${params.contextPath}/web/elderHealth/<#if (params.id)??>modify<#else>save</#if>.json"
                      method="post">
                    <input type="hidden" name="id" value="${params.id}"/>

                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">老人姓名<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="hidden" name="elderId"/>
                                            <input type="text" name="name" placeholder="请选择老人"
                                                   p="model:'elder',handlerId:'elder_handler_select'"
                                                   class="layui-input single-model-select {required:true}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">体检日期<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="physicalExaminationTime" placeholder="请输入体检日期"
                                                   class="layui-input ui-date {required:true}" readonly/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">责任医生<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="doctorId" placeholder="请输入责任医生" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">症状<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="checkbox" name="symptom" value="无症状" title="无症状">
                                            <input type="checkbox" name="symptom" value="头痛" title="头痛">
                                            <input type="checkbox" name="symptom" value="头晕" title="头晕">
                                            <input type="checkbox" name="symptom" value="心悸" title="心悸">
                                            <input type="checkbox" name="symptom" value="胸闷" title="胸闷">
                                            <input type="checkbox" name="symptom" value="胸痛" title="胸痛">
                                            <input type="checkbox" name="symptom" value="慢性咳嗽" title="慢性咳嗽">
                                            <input type="checkbox" name="symptom" value="咳痰" title="咳痰">
                                            <input type="checkbox" name="symptom" value="呼吸困难" title="呼吸困难">
                                            <input type="checkbox" name="symptom" value="多饮" title="多饮">
                                            <input type="checkbox" name="symptom" value="多尿" title="多尿">
                                            <input type="checkbox" name="symptom" value="体重下降" title="体重下降">
                                            <input type="checkbox" name="symptom" value="乏力" title="乏力">
                                            <input type="checkbox" name="symptom" value="关节肿痛" title="关节肿痛">
                                            <input type="checkbox" name="symptom" value="视力模糊" title="视力模糊">
                                            <input type="checkbox" name="symptom" value="手脚麻木" title="手脚麻木">
                                            <input type="checkbox" name="symptom" value="尿急" title="尿急">
                                            <input type="checkbox" name="symptom" value="尿痛" title="尿痛">
                                            <input type="checkbox" name="symptom" value="便秘" title="便秘">
                                            <input type="checkbox" name="symptom" value="腹泻" title="腹泻">
                                            <input type="checkbox" name="symptom" value="恶心呕吐" title="恶心呕吐">
                                            <input type="checkbox" name="symptom" value="眼花" title="眼花">
                                            <input type="checkbox" name="symptom" value="耳鸣" title="耳鸣">
                                            <input type="checkbox" name="symptom" value="乳房胀痛" title="乳房胀痛">
                                            <input type="checkbox" name="symptom" value="其他" title="其他">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">其他症状备注<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="symptomRemark" placeholder="请输入其他症状备注" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">体温(℃)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="temperature" placeholder="请输入体温" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">脉率(次/分钟)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="pulseRate" placeholder="请输入脉率" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">呼吸频率(次/分钟)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="respirationRate" placeholder="请输入呼吸频率" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">左侧血压(mmHg)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="leftBloodPressure" placeholder="请输入左侧血压" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">右侧血压(mmHg)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="rightBloodPressure" placeholder="请输入右侧血压" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">身高(cm)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="height" placeholder="请输入身高" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">体重(kg)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="weight" placeholder="请输入体重" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">腰围(cm)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="waistline" placeholder="请输入腰围" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">体质指数(kg/m2)<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="bmi" placeholder="请输入体质指数" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">健康自我评估<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <select name="healthSelfAppraisal" class="layui-input">
                                                <option value="">请选择</option>
                                                <option value="满意">满意</option>
                                                <option value="基本满意">基本满意</option>
                                                <option value="说不清楚">说不清楚</option>
                                                <option value="不太满意">不太满意</option>
                                                <option value="不满意">不满意</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">自理能力自我评估<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <select name="selfcareAbilityAppraisal" class="layui-input">
                                                <option value="">请选择</option>
                                                <option value="可自理">可自理(0~3分)</option>
                                                <option value="轻度依赖">轻度依赖(4~8分)</option>
                                                <option value="中度依赖">中度依赖(9~18分)</option>
                                                <option value="不能自理">不能自理(≥19分)</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>


                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">认知功能<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <select name="cognitiveFunction" class="layui-input">
                                                <option value="">请选择</option>
                                                <option value="粗筛阴性">粗筛阴性</option>
                                                <option value="粗筛阳性">粗筛阳性</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">简易智力状态检查分数<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="cognitiveFunctionScore" placeholder="请输入简易智力状态检查分数"
                                                   class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-row">
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">情感状态<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <select name="affectiveState" class="layui-input">
                                                <option value="">请选择</option>
                                                <option value="粗筛阴性">粗筛阴性</option>
                                                <option value="粗筛阳性">粗筛阳性</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">老年人抑郁评分检查分数<span class="ui-request">*</span></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="affectiveStateScore" placeholder="请输入老年人抑郁评分检查分数"
                                                   class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-md12">
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <input type="submit" value="保存" class="layui-btn"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <#--end-->
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="layui-tab-item">
            <iframe id="elderLifeStyle" style="border: none" width="100%" height="800px" src="${params.contextPath}/view/business/elderLifeStyle/elderLifeStyle_edit.htm"></iframe>
        </div>
        <div class="layui-tab-item">
            <iframe id="elderOrganFunction" style="border: none" width="100%" height="800px" src="${params.contextPath}/view/business/elderOrganFunction/elderOrganFunction_edit.htm"></iframe>
        </div>
        <div class="layui-tab-item">
            <iframe id="elderHealthQuestion" style="border: none" width="100%" height="800px" src="${params.contextPath}/view/business/elderHealthQuestion/elderHealthQuestion_edit.htm"></iframe>
        </div>
        <div class="layui-tab-item">
            <iframe id="elderHospitalization" style="border: none" width="100%" height="800px" src="${params.contextPath}/view/business/elderHospitalization/elderHospitalization_edit.htm"></iframe>
        </div>
        <div class="layui-tab-item">
            <iframe id="elderPharmacy" style="border: none" width="100%" height="800px" src="${params.contextPath}/view/business/elderPharmacy/elderPharmacy_edit.htm"></iframe>
        </div>
        <div class="layui-tab-item">
            <iframe id="elderHealthEvaluation" style="border: none" width="100%" height="800px" src="${params.contextPath}/view/business/elderHealthEvaluation/elderHealthEvaluation_edit.htm"></iframe>
        </div>
    </div>
</div>


</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
<script>
    layui.use('element', function () {
        var $ = layui.jquery
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        element.on('tab(test)', function (elem) {
            var index = elem.index;
            var src=$(".layui-tab-item:eq("+index+")").find("iframe").attr("src");
            $(".layui-tab-item:eq("+index+")").find("iframe").attr("src",src);
        });

        //Hash地址的定位
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

    });

</script>

    <script type="text/javascript">
        $(function () {
            var form = layui.form;
            form.render();
        });
        LocalStorage.registHandler("elder_handler_select", function (data) {
            $('input[name="elderId"]').val(data.id);
            $('input[name="name"]').val(data.name);
        });
    $(function () {
        <#if (params.id)??>
        $.ajaxRequest({
            url: '${params.contextPath}/web/elderHealth/query.json',
            data: {id: "${params.id}"},
            success: function (data) {
                if (!data.success) {
                    $.message(data.message);
                    return;
                }
                // 获取体检主表
                var record = data.data;
                for (var key in record) {
                    if (key == 'symptom') {
                        // 获取症状
                        var symptom = record.symptom;
                        var symptomArray = symptom.split(",");
                        var symptomAll = $("input[name='symptom']");
                        for(var i=0; i<symptomArray.length; i++){
                            debugger;
                            //获取所有复选框对象的value属性，然后，symptomArray[i]和他们匹配，如果有，则说明他应被选中
                            $.each(symptomAll,function(j,checkbox){
                                //获取复选框的value属性
                                var checkValue = $(checkbox).val();
                                if(symptomArray[i] == checkValue){
                                    $(checkbox).attr("checked",true);
                                    // $(checkbox).next().addClass('layui-form-checked');
                                }
                            });
                        }
                    } else if (key == 'healthSelfAppraisal') {
                        // 获取健康自我评估
                        var healthSelfAppraisal = record.healthSelfAppraisal;

                        $("select[name='healthSelfAppraisal']").val(healthSelfAppraisal);

                    } else if (key == 'selfcareAbilityAppraisal') {
                        // 自理能力自我评估
                        var selfcareAbilityAppraisal = record.selfcareAbilityAppraisal;
                        $("select[name='selfcareAbilityAppraisal']").val(selfcareAbilityAppraisal);
                    } else if (key == 'affectiveState') {
                        // 情感状态
                        var affectiveState = record.affectiveState;
                        $("select[name='affectiveState']").val(affectiveState);

                    } else if (key == 'cognitiveFunction') {
                        // 认知功能
                        var cognitiveFunction = record.cognitiveFunction;
                        $("select[name='cognitiveFunction']").val(cognitiveFunction);

                    } else {
                        $("[name='" + key + "']").val(record[key]);
                    }
                }
                $("[name='physicalExaminationTime']").val(record.physicalExaminationTimeStr);
                $("#elderLifeStyle").attr("src", $.getUrl("${params.contextPath}/view/business/elderLifeStyle/elderLifeStyle_edit.htm", "healthId", record.id));
                $("#elderOrganFunction").attr("src", $.getUrl("${params.contextPath}/view/business/elderOrganFunction/elderOrganFunction_edit.htm", "healthId", record.id));
                $("#elderHealthQuestion").attr("src", $.getUrl("${params.contextPath}/view/business/elderHealthQuestion/elderHealthQuestion_edit.htm", "healthId", record.id));
                $("#elderHospitalization").attr("src", $.getUrl("${params.contextPath}/view/business/elderHospitalization/elderHospitalization_edit.htm", "healthId", record.id));
                $("#elderPharmacy").attr("src", $.getUrl("${params.contextPath}/view/business/elderPharmacy/elderPharmacy_edit.htm", "healthId", record.id));
                $("#elderHealthEvaluation").attr("src", $.getUrl("${params.contextPath}/view/business/elderHealthEvaluation/elderHealthEvaluation_edit.htm", "healthId", record.id));
                var form = layui.form;
                form.render();
            }
        });
        </#if>
    });
</script>

</html>
